package com.nxy.test.netty.initializer;

import com.nxy.test.netty.handle.HttpRequestHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.stream.ChunkedWriteHandler;

/**
 * Created by snailnan on 2017/3/1.
 */
public class HttpInitalizer extends ChannelInitializer<SocketChannel>{
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline()
        .addLast(new HttpServerCodec())
        .addLast(new HttpObjectAggregator(64*1024))
        .addLast(new ChunkedWriteHandler())
        .addLast("httpRequest",new HttpRequestHandler());
    }
}
